package com.eastfair.home.controller;

import com.eastfair.annotation.annotation.log.SysLog;
import com.eastfair.home.dto.*;
import com.eastfair.home.entity.ExhibitionManageNotice;
import com.eastfair.home.service.ExhibitionManageNoticeService;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.eastfair.boot.controller.SuperController;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eastfair.echo.core.EchoService;
import com.eastfair.core.base.R;
import com.eastfair.home.vo.ExhibitionManageContactVO;
import com.eastfair.home.vo.ExhibitionManageNoticeVO;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.eastfair.annotation.annotation.security.PreAuth;

import com.eastfair.boot.request.PageParams;
import com.eastfair.core.context.ContextUtil;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 前端控制器
 * 展会须知
 * </p>
 *
 * @author linan
 * @date 2022-10-22
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/exhibitionManageNotice")
@Api(value = "ExhibitionManageNotice", tags = "展会须知")
@PreAuth(replace = "home:exhibitionManageNotice:")
public class ExhibitionManageNoticeController extends SuperController<ExhibitionManageNoticeService, Long, ExhibitionManageNotice, ExhibitionManageNoticePageQuery, ExhibitionManageNoticeSaveDTO, ExhibitionManageNoticeUpdateDTO> {

    @Autowired
    private EchoService echoService;

    @Override
    public void handlerResult(IPage<ExhibitionManageNotice> page) {
        // 想让返回值实现自动回显，请将此行代码打开
        // echoService.action(page);
    }
    /**
     * Excel导入后的操作
     *
     * @param list
     */
    @Override
    public R<Boolean> handlerImport(List<Map<String, String>> list){
        List<ExhibitionManageNotice> exhibitionManageNoticeList = list.stream().map((map) -> {
            ExhibitionManageNotice exhibitionManageNotice = ExhibitionManageNotice.builder().build();
            //TODO 请在这里完成转换
            return exhibitionManageNotice;
        }).collect(Collectors.toList());

        return R.success(baseService.saveBatch(exhibitionManageNoticeList));
    }



    /**
     * 处理参数
     *
     * @param params 分页参数
     */
    @Override
    public void handlerQueryParams(PageParams<ExhibitionManageNoticePageQuery> params) {
        ExhibitionManageNoticePageQuery pageQuery = params.getModel();

    }



    /**
     * 编辑展会须知
     * @param params params
     * @return R<Boolean>
     */
    @SysLog("修改展会须知")
    @PostMapping("/updateExhibitionNotice")
    public R<Boolean> updateExhibitionNotice(@RequestBody ExhibitionManageNoticeDTO params){
        return  R.success(baseService.updateExhibitionNotice(params));
    }

    /**
     * 查询展会须知
     * @param params params
     * @return R<Boolean>
     */
    @PostMapping("/queryExhibitionNotice")
    public R<ExhibitionManageNoticeVO> queryExhibitionNotice(@RequestBody ExhibitionManageNoticePageQuery params){
        return  R.success(baseService.queryExhibitionNotice(params));
    }
}
